<HTML><HEAD><TITLE>read_item(+Stream, -Item)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(flatzinc_parser)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>read_item(+Stream, -Item)</H1>
Read one item from a FlatZinc input stream
<DL>
<DT><EM>Stream</EM></DT>
<DD>ECLiPSe stream name or handle
</DD>
<DT><EM>Item</EM></DT>
<DD>Output: an ECLiPSe term that describes the FlatZinc item
</DD>
</DL>
<H2>Description</H2>
<P>
	Reads one FlatZinc item (up to and including the terminating
	semicolon) from Stream, and returns it as an ECLiPSe structure.
	Fails when end_of_file has been reached.
    </P>
<H3>Modes and Determinism</H3><UL>
<LI>read_item(+, -) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if end_of_file is reached
<H3>Exceptions</H3>
<DL>
<DT><EM>(fz_abort) </EM>
<DD>syntax error
</DL>
<H2>Examples</H2>
<PRE>
    ?- read_item(input, Item).
    &gt; float: x=3.14;
    Item = float : x = 3.14
    Yes (0.00s cpu)

    ?- read_item(input, Item).
    &gt; solve minimize x;
    Item = minimize(solve, x)
    Yes (0.03s cpu)

    ?- read_item(input, Item).
    &gt; var int: i::foo::bar;
    Item = var(int) : (i :: (foo :: bar))
    Yes (0.02s cpu)

    ?- read_item(input, Item).
    &gt; constraint int_lt(x[2], 3);
    Item = constraint(int_lt(subscript(x, [2]), 3))
    Yes (0.00s cpu)

    ?- read_item(input, Item).
    &gt; set of  int: s={1,2,3};
    Item = (set of int) : s = {[1, 2, 3]}
    Yes (0.05s cpu)

    ?- read_item(input, Item).
    &gt; array [1..3] of var int: a;
    Item = (array([1 .. 3]) of var(int)) : a
    Yes (0.03s cpu)

    ?- read_item(input, Item).
    &gt; var 1..5: i;
    Item = var(1 .. 5) : i
    Yes (0.03s cpu)

</PRE>

</BODY></HTML>
